<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Dados Cliente"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form>
                <h:panelGrid columns="7" style="margin-bottom: 20px;">
                    <h:commandButton styleClass="btn btn-mini btn-primary" action="#{clienteController.prepareEditView()}" value="Editar cliente" />
                    <p:spacer width="10" height="10"/>
                    <h:commandButton styleClass="btn btn-mini btn-primary" action="#{clienteController.prepareCreate}" value="Novo cliente" />
                    <p:spacer width="10" height="10"/>
                    <h:commandButton styleClass="btn btn-mini btn-primary" action="#{clienteController.fazerPedido(clienteController.selected)}" value="Fazer pedido"/>
                    <p:spacer width="10" height="10"/>
                    <h:commandButton styleClass="btn btn-mini btn-primary" action="/cadastro/cliente/List.xhtml" value="Clientes"/>
                </h:panelGrid>
                <fieldset>
                    <legend align="left"><h:outputText value="#{clienteController.selected.nome}"/></legend>
                    <div class="row">
                        <div class="col-md-3" align="left">
                            <h:outputText value="Código:" style="font-style: oblique;"/>
                        </div>
                        <div class="col-md-3" align="left">
                            <h:outputText value="#{clienteController.selected.id}"/>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-3" align="left">
                            <h:outputText value="Data cadastro:" style="font-style: oblique;"/>
                        </div>
                        <div class="col-md-3" align="left">
                            <h:outputText value="#{clienteController.selected.dataCadastro}" >
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>                            
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-3" align="left">
                            <h:outputText value="Contatos:" style="font-style: oblique;"/>
                        </div>
                        <div class="col-md-3" align="left">
                            <ui:repeat value="#{clienteController.selected.telefones}" var="tel">
                                <h:outputText value="(#{tel.ddd})#{tel.telefone}"/>&nbsp;
                            </ui:repeat>
                        </div>
                    </div>

                    <ui:repeat value="#{clienteController.selected.endereco}" var="item">
                        <div class="row">
                            <div class="col-md-3" align="center">
                                <h:outputText value="Endereço" />
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Logradouro:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.logradouro.label}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Nome Logradouro:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.nome}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="CEP:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.cep}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Bairro:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.bairro}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Número:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.numero}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Cidade:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.cidade}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Estado:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-3" align="left">
                                <h:outputText value="#{item.estado}"/>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-3" align="left">
                                <h:outputText value="Complemento:" style="font-style: oblique;"/>
                            </div>
                            <div class="col-md-5" align="left">
                                <h:outputText value="#{item.complemento}"/>
                            </div>
                        </div>
                    </ui:repeat>
                </fieldset>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
